//
//  CQLoadingView.m
//  PLRLiveShow
//
//  Created by 赵小燕 on 2017/8/15.
//  Copyright © 2017年 xiaoyanzhao. All rights reserved.
//

#import "CQLoadingView.h"

@interface CQLoadingView () {
    
    UILabel *loadingInfoLabe;
}

@end

@implementation CQLoadingView

static CQLoadingView *loadingView = nil;

// loading图单例
+ (instancetype)sharedInstance {
//    if (loadingView == ni)
    static dispatch_once_t onceToken = 0;
    dispatch_once(&onceToken, ^{
            loadingView = [[self alloc] init];
    });
    return loadingView;
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor colorWithWhite:0.2 alpha:0.2];
        
        UIImageView *loadingImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 45, 45)];
        [self addSubview:loadingView];
        loadingImageView.image = [UIImage imageNamed:nil];
        
        NSMutableArray *imageArray = [NSMutableArray array];
        for (int i = 0; i < 15; i++) {
            NSString *imageName = [NSString stringWithFormat:@"loading_%5d", i];
            [imageArray addObject:[UIImage imageNamed:imageName]];
        }
        loadingImageView.animationImages = imageArray;
        loadingImageView.animationDuration = 0.5;
        loadingImageView.animationRepeatCount = 0;
    }
    return self;
}

@end
